package day8homework;

import java.util.Scanner;

public class Bank {
	//账户
	private int account; 
	//姓名
	private String name;
	//地址
	private String address;
	//存款余额
	private double balance;  
	//最小余额
	private double minBalance;
	Scanner input = new Scanner(System.in);
	public void work(){
		while(true){
			System.out.println("======================================");
			System.out.println("\t\t" + name + "您好");
			System.out.println("\t欢迎使用银行管理信息系统");
			System.out.println("\t\t1、取款");
			System.out.println("\t\t2、存款");
			System.out.println("\t\t3、查询");
			System.out.println("\t\t4、退出");
			System.out.println("======================================");
			System.out.println("请输入您想使用的功能：");
			int result = input.nextInt();
			if(result == 4){
				System.out.println("退出成功");
				break;
			}
			switch (result) {
			case 1:
				System.out.println("请输入取款金额：");
				double money1 = input.nextDouble();
				withdraw(money1);
				break;
			case 2:
				System.out.println("请输入存款金额：");
				double money2 = input.nextDouble();
				deposit(money2);
				break;
			case 3:
				query();
				break;
			default:
				System.out.println("输入错误，请重新输入");
			}
		}
	}
	@Override
	public String toString() {
		return "Bank [account=" + account + ", name=" + name + ", address=" + address + ", balance=" + balance
				+ ", minBalance=" + minBalance + "]";
	}
	//构造方法
	public Bank() {
		
	}
	//有参方法
	public Bank(int account, String name, String address, double balance, double minBalance) {
		super();
		this.account = account;
		this.name = name;
		this.address = address;
		this.balance = balance;
		this.minBalance = minBalance;
	}
	//存款方法
	public void deposit(double money) {
		System.out.println("储户原有余额：" + balance);
		System.out.println("今日存款数额：" + money);
		balance += money;
		System.out.println("存款后余额：" + balance);
	}
	//取款方法
	public void withdraw(double money) {
		if(balance - money < minBalance) {
			System.out.println("取款失败，至少保留余额" + minBalance);
		}
		else {
			balance -= money;
			System.out.println("成功取款 " + money + "元" + "\n" + "取款后余额：" + balance);
		}
	}
	//查询方法
	public void query() {
		System.out.println("余额为：" + balance);
	}
	public int getAccount() {
		return account;
	}
	public void setAccount(int account) {
		this.account = account;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public double getBalance() {
		return balance;
	}
	public void setBalance(double balance) {
		this.balance = balance;
	}
	public double getMinBalance() {
		return minBalance;
	}
	public void setMinBalance(double minBalance) {
		this.minBalance = minBalance;
	}
	public Scanner getInput() {
		return input;
	}
	public void setInput(Scanner input) {
		this.input = input;
	}
	
}
